/*
 * @Author: '浪川' '1214391613@qq.com'
 * @Date: 2025-07-17 14:56:15
 * @LastEditors: '浪川' '1214391613@qq.com'
 * @LastEditTime: 2025-07-17 17:07:01
 * @FilePath: \passiflora-edulis-sims\src\stores\canvas-store.ts
 * @Description: 书本的尺寸设置
 *
 * Copyright (c) 2025 by '1214391613@qq.com', All Rights Reserved.
 */
import { defineStore, acceptHMRUpdate } from 'pinia'
import type { ICanvas } from 'src/interfaces/IBook'
import { unit2px } from 'src/utils/LeaferUtil'

export const useCanvasStore = defineStore('Canvas', {
  state: (): ICanvas => ({
    width: 8.268,
    height: 11.693,
    unit: 'in',
    ppi: 300,
  }),

  getters: {
    canvas(): ICanvas {
      return {
        width: unit2px(this.width, this.unit, this.ppi),
        height: unit2px(this.height, this.unit, this.ppi),
        unit: this.unit,
        ppi: this.ppi,
      }
    },
  },
})

if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useCanvasStore, import.meta.hot))
}
